// @ts-ignore
/* eslint-disable */
import {request} from 'umi';
import {RiskListItem} from './data';

export async function dataList(type: string) {
  return request<{
    data: RiskListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/risk-map/list', {
    method: 'GET',
    params: {
      type,
      pageNum: 1,
      pageSize: 100,
      orderByColumn: "createTime",
      isAsc: 'desc',
    },
  });
}

export async function loadCheckRisk(params: {
  // query
  /** 当前的页码 */
  current?: number;
  /** 页面的容量 */
  pageSize?: number;
}) {
  return request<{
    data: RiskListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/v2/enterprise/risk/list', {
    method: 'GET',
    params: {
      ...params,
      pageNum: params.current,
      // orderByColumn: "riskSort",
      isAsc: 'desc',
      type: 1,
    },
  });
}

export async function getRisk(param: { riskId?: number }): Promise<{ data: RiskListItem }> {
  console.log(param);
  return request(`/v2/enterprise/risk/${param.riskId}`, {method: 'GET'});
}

export async function addRisk(param: RiskListItem): Promise<{ data: number }> {
  return request('/v2/enterprise/risk', {method: 'POST', data: param});
}

export async function updateRisk(param: RiskListItem): Promise<{ data: number }> {
  return request('/v2/enterprise/risk', {method: 'PUT', data: param});
}

export async function checkRisk(param: RiskListItem): Promise<{ data: number }> {
  return request('/v2/enterprise/risk/check', {method: 'PUT', data: param});
}

export async function rejectRisk(param: RiskListItem): Promise<{ data: number }> {
  return request('/v2/enterprise/risk/reject', {method: 'PUT', data: param});
}

export async function removeData(data: number[]) {
  return request<Record<string, any>>(`/v2/enterprise/risk-map/` + data.join(), {method: 'DELETE'});
}
